<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>支付成功</title>
    <style>
        .box {
            margin: 50px 400px;
        }
        
        .box p span {
            font-size: 24px;
            color: red;
        }
    </style>
</head>

<body>
    <div class="box">
        <h1>恭喜你，支付成功！</h1>
        <p><span id="time">10</span> 秒后自动返回首页</p>
        <button>立即返回</button>
    </div>
    <script>
        window.onload = function() {
            setInterval('timer()', 1000);
        }

        document.getElementsByTagName('button')[0].onclick = function() {
            location.href = 'index.html ';
        }

        var times = 10;

        function timer() {
            times--;
            document.getElementById('time').innerText = times;
            if (times == 0) {
                location.href = 'index.html ';
            }

        }
    </script>

</body>

</html>